﻿using System;
using System.Collections;
using System.Collections.Generic;

using AUV5.Model;
using AUV5.DAL.Interface;

namespace AUV5.DAL.Dao
{
    /// <summary>
    /// 功能：     OrderLog业务接口的实现
    /// 作者：     Wilson
    /// 日期：     2011/12/1
    /// 修改日期： 
    /// 修改人：
    /// 修改内容：
    /// </summary>
    public class OrderLogSqlMapDao : BaseSqlMapDao, AUV5.DAL.Interface.IOrderLogDao
    {
        private static OrderLogSqlMapDao instance = new OrderLogSqlMapDao();

        private OrderLogSqlMapDao()
        {
            //
            // TODO: 此处添加OrderLogSqlMapDao的构造函数
            //
        }

        public static IOrderLogDao GetInstance()
        {
            return instance;
        }

        /// <summary>
        /// 得到最大行数
        /// </summary>
        /// <returns></returns>
        public int GetMaxCounts()
        {
            try
            {
                return (int)ExecuteQueryForObject("SelectOrderLogByMaxCounts", null);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 得到列表
        /// </summary>
        /// <returns></returns>
        public System.Collections.Generic.IList<OrderLog> GetList()
        {
            try
            {
                return ExecuteQueryForList<OrderLog>("SelectOrderLog", null);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 通过不同参数得到列表
        /// </summary>
        /// <param name="objParameters"></param>
        /// <returns></returns>
        public System.Collections.Generic.IList<OrderLog> GetListByParameters(object objParameters)
        {
            try
            {
                return ExecuteQueryForList<OrderLog>("SelectOrderLogByParameters", objParameters);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 得到明细
        /// </summary>
        /// <param name="HistoryId"></param>
        /// <returns></returns>
        public OrderLog GetDetail(System.String historyid)
        {
            try
            {
                return ExecuteQueryForObject<OrderLog>("SelectOrderLog", historyid) as OrderLog;
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 新建
        /// </summary>
        /// <param name="orderlog"></param>
        /// <returns></returns>
        public object Add(OrderLog orderlog)
        {
            //int id = GetId("OrderLog");
            //orderlog.HistoryId = id;

            try
            {
                return ExecuteInsert("InsertOrderLog", orderlog);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="orderlog"></param>
        /// <returns></returns>
        public int Update(OrderLog orderlog)
        {
            try
            {
                return ExecuteUpdate("UpdateOrderLog", orderlog);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="HistoryId"></param>
        /// <returns></returns>
        public int Delete(System.String historyid)
        {
            try
            {
                return ExecuteDelete("DeleteOrderLog", historyid);
            }
            catch
            {
                throw;
            }
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="orderlog"></param>
        /// <returns></returns>
        public int Delete(OrderLog orderlog)
        {
            try
            {
                return ExecuteDelete("DeleteOrderLog", orderlog.HistoryId);
            }
            catch
            {
                throw;
            }
        }

        #region##通地订单ID得到订单聊天集合
        /// <summary>
        /// 通地订单ID得到订单聊天集合
        /// 创建人：Wilson
        /// 创建时间：2011-12-2
        /// </summary>
        /// <param name="objParameters"></param>
        /// <returns></returns>
        public IList<OrderLog> GetListByOrderId(object objParameters)
        {
            try
            {
                return ExecuteQueryForList<OrderLog>("SelectOrderLogListByOrderID", objParameters);
            }
            catch
            {
                throw;
            }
        }
        #endregion
    }
}
